<template>
  <el-container class="home_container">
    <!-- 头部区域 -->
    <el-header>
      <!-- 左侧logo和标题 -->
      <div>
        <img class="logo_img" src="../assets/logo.png" alt="">
        <span>兰铁通信调度管理</span>
      </div>

      <el-menu
        :default-active="activeIndex"
        class="el-menu-demo"
        mode="horizontal"
        background-color="#373d41"
        text-color="#fff"
        active-text-color="#409EFF"
        router>
        <el-menu-item index="/welcome" @click="saveActivePath('/welcome')">首页</el-menu-item>
        <el-menu-item index="/todayWork"  @click="saveActivePath('/todayWork')">当日工作安排</el-menu-item>
        <el-menu-item index="/task"  @click="saveActivePath('/task')">生成调度</el-menu-item>
        <el-menu-item index="/dataAnalyze"  @click="saveActivePath('/dataAnalyze')">数据分析</el-menu-item>
        <el-menu-item index="/watch"  @click="saveActivePath('/watch')">值班值守</el-menu-item>
        <el-menu-item index="/watch"  @click="saveActivePath('/watch')">重点工作提示</el-menu-item>
        <el-menu-item  index="/server"  @click="saveActivePath('/server')">后台管理</el-menu-item>
      </el-menu>

      <el-button @click="logout" type="info">退出</el-button>
    </el-header>
    <!-- 页面主体区域 -->
    <el-main>
      <router-view></router-view>
    </el-main>
  </el-container>
</template>

<script>
import Weather from "./Weather";
export default {
  name: 'Home',
  components: {Weather},
  data(){
    return{
      activeIndex : '/home',
    }
  },
  created(){
    this.activeIndex =  window.sessionStorage.getItem("hPath");
  },
  methods: {
    logout () {
      window.sessionStorage.clear()
      this.$router.push('/login')
    },
    saveActivePath(active){
        window.sessionStorage.setItem('hPath',active)
    }

  }
}
</script>
<style lang="less" scoped>
.home_container {
  height: 100%;

}
.el-menu.el-menu--horizontal{
    border-bottom: none;
}
.el-header {
  background-color: #373d41;
  display: flex;
  justify-content: space-between;
  padding-left: 0;
  align-items: center;
  color: #ffffff;
  font-size: 20px;

  > div {
    display: flex;
    align-items: center;
    span {
      margin-left: 15px;
    }
  }
}

.el-aside {
  background-color: #373d41;
  width: 100%;
  .el-menu {
    border-right: none;
    width: 100%;
  }
}

.logo_img {
  background-color: #373d41;
  border: 1px solid #eeeeee;//边框
  border-radius: 50%;//圆角
  height: 60px;
  width: 60px;
  background-color: #ffffff;
  box-shadow: 0 0 10px #dddddd;//给边框加阴影
}
  .el-main{
    padding: 0;
    height: 100%;
  }
</style>
